<?php

if ( ! defined("IN_OP") )
{
    exit("You can't access this file directly...");
}
if ( $curruser['prev_id'] != 0 && ! SubAccountRight($curruser , 1) )
{
    diemsg("你不是管理者！");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chkGametype = chkGametype($gametype);
$chk = new CheckMode_3d($curruser['acl'] , 1 , $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
$show5N = getShow35($gametype);
$betname_3d = judge_type($gametype);
unset($chk);
$ui = new UI_3D(true);
$tpl = new Template2();
$conf = new Config();
if ( $chkGametype == 3 )
{
    require_once( "class_5h/RateConfig_5h.php" );
    require_once( "class_5h/SRate_5h.php" );
    $RateConfig_3d = new RateConfig_5h($gametype);
    $SRate_3d = new SRate_5h($gametype);
    if ( $g_gametype_3d[$gametype]['en'] == "5h" )
    {
        $_5hFlag = 1;
        $_8hFlag = 0;
    }
    else
    {
        $_5hFlag = 0;
        $_8hFlag = 1;
    }
    $tempOrderArr = array ( );
}
elseif ( $chkGametype == 4 )
{
    require_once( "class_sb/RateConfig_sb.php" );
    require_once( "class_sb/SRate_sb.php" );
    $RateConfig_3d = new RateConfig_sb($gametype);
    $SRate_3d = new SRate_sb($gametype);
    $_5hFlag = 0;
	$_8hFlag = 0;
    $tempOrderArr = array ( );
}
else
{
    $_5hFlag = 0;
    $_8hFlag = 0;
    require_once( "class_3d/RateConfig_3d.php" );
    require_once( "class_3d/SRate_3d.php" );
    $RateConfig_3d = new RateConfig_3d($gametype);
    switch ( $show3D3S )
    {
        case 0 :
            $SRate_3d = new SRate_3d($gametype);
            break;
        case 1 :
            $SRate_3d = new SRate_3s($gametype);
            unset($RateConfig_3d->playtypeArr02['r1pass']);
            break;
    }
    $tempOrderArr = array ( "r1" => "r1" , "r1p" => "r1p" , "g3" => "g3" , "g6" => "g6" );
}
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$pg = $g_gametype_3d[$gametype]['pg'];
$split = 1;
$disk = 0;
$order = 2;
$playtype = getvar("playtype");
$id = getvar("id");
$bid = getvar("bid");
$ratemod = 0;
if ( $id == "" )
{
    $showday = date("Y-m-d");
    $lottoData = $SRate_3d->getLotto3DByDate($showday);
}
else
{
    $id = intval($id);
    $lottoData = $SRate_3d->getLotto3DById($id);
    $showday = $lottoData['open'];
}
if ( $lottoData == "" )
{
    $ui->showErrorPage("目前没有{$tblName}可以下注期数！" , true);
    exit();
}
$split = 1;
$playtype = isset($RateConfig_3d->playtypeArr02[$playtype])?$playtype:"r1";
if ( $bid != "" )
{
    $fieldsArr = array ( $bid );
}
else
{
    $fieldsArr = $RateConfig_3d->playGroupArr02[$playtype];
}
$bidstr = "";
if ( $bid == "" )
{
    $bidstr = "";
}
else
{
    $bid == intval($bid);
    if ( ! in_array($bid , $RateConfig_3d->playGroupArr02[$playtype]) )
    {
        diemsg("{$tblName}玩法资料错误。");
    }
    $bidstr = "&bid=".$bid;
    $tpl->set("bid" , $bid);
}
$menu_list_url = "";
$tempUrl = "op.php?op=admin&fp=unow_3d&gametype={$gametype}&playtype=";
$tempArr = array ( );
if ( $show5N )
{
    $jsFuname = "_n5";
    $jsFunameFlag = "true";
}
else
{
    $jsFuname = "";
    $jsFunameFlag = "false";
}
if ( ! $_5hFlag )
{
    unset($RateConfig_3d->playtypeArr02['rcmp']);
}
else
{
    $xyid = intval(getvar("xyid"));
    $tempArr[] = "<th width='10%'>".getOptionXYList($xyid , false , "" , "xyid" , "xyid")."<span id='noxystr' class='noneRateRecord'>单一盘</span></th>";
}
foreach ( $RateConfig_3d->playtypeArr02 as $key => $val )
{
    $showUrl = $tempUrl.$key;
    if ( $playtype == $key )
    {
        $tempClass = " class=\"cbig\"";
    }
    else
    {
        $tempClass = "";
    }
    $tempArr[] = "<th {$tempClass} id='myThBar{$key}' ><a href=\"javascript:clickTitle('{$key}');\">{$val}</a><br />(<span style='color:#cc0000' id='spanPageAmount{$key}'></span>)</th>";
}
$menu_list_url = implode("" , $tempArr);
switch ( $chkGametype )
{
    case 1 :
        $stopbet_3d = $conf->get("stopbet_{$tbl}");
        if ( $stopbet_3d == "0000" )
        {
            $stopbet_3d = "2359";
        }
        $tempStrInt = false;
        break;
    case 2 :
    case 3 :
	case 4 :
        $tempStrInt = strtotime($lottoData['stopbet']);
        break;
}
if ( $tempStrInt == false )
{
    $h = substr($stopbet_3d , 0 , 2);
    $m = substr($stopbet_3d , 2);
    $tempStr = "{$showday} {$h}:{$m}:00";
    $timetamp = systime();
    $timetamplimit = strtotime($tempStr) - $timetamp;
}
else
{
    $timetamp = systime();
    $timetamplimit = $tempStrInt - $timetamp;
}
$disabledbet = "";
if ( $timetamplimit < 1 )
{
    $disabledbet = "disabled=\"disabled\"";
}
$tpl->load("main" , "unow_3d.htm");
$quickBtnDisplay = "";
if ( isset($tempOrderArr[$playtype]) )
{
    $order = 2;
}
$tempSlc = "<select name=\"BtnNote\" style='display:none'>";
$tempSlc .= "<option value=''>请选择...</option>";
$i = 0;
while ( $i < 10 )
{
    $tempUser = $conf->get("port_systemuser_{$i}");
    if ( $tempUser != "" )
    {
        $tempSlc .= "<option value=\"{$i}\">{$tempUser}</option>";
    }
    ++ $i;
}
$tempSlc .= "</select>";
$tpl->set(array ( "playtype" => $RateConfig_3d->playtypeArr02[$playtype] , "menu_list_url" => $menu_list_url , "lotto_id_3d" => $lottoData['id'] , "round" => $_5hFlag || $_8hFlag?$lottoData['round']:d3($lottoData['round']) , "open" => $lottoData['open'] , "timetamp" => $timetamp , "timetamplimit" => $timetamplimit , "playtypestr" => $playtype , "split" => $split , "order" => $order , "disk" => $disk , "ratemod" => $ratemod , "gametype" => $gametype , "gametypeStr" => $tblName , "reloadCK" => "30" , "jsLang" => $g_conf['language'] , "jsFuname" => $jsFuname , "port_systemuser" => $tempSlc ));
$jslink = "<script src=\"js_3d/jquery-ui-1.8.11.custom.min.js\"></script>\n";
$jslink .= "<script src=\"js_3d/showRateRecord.js\"></script>\n";
$jslink .= "<script src=\"js_3d/js3d.js\"></script>\n";
$jslink .= "<script>";
$jslink .= "var __roundID = ".$lottoData['id'].";";
$jslink .= "var __reloadCK = 0;";
$jslink .= "var now = new Date(1000 * {$timetamp});";
$jslink .= "var timestap = {$timetamplimit};";
$jslink .= "var myGlobalVal = {};";
$jslink .= "myGlobalVal.gametype = '{$gametype}';";
$jslink .= "myGlobalVal.lotto_id_3d = ".$lottoData['id'].";";
$jslink .= "myGlobalVal.playtypestr = '{$playtype}';";
$jslink .= "myGlobalVal.open = '".$lottoData['open']."';";
$jslink .= "myGlobalVal.reloadCK = '60';";
$jslink .= "myGlobalVal.jsFuname = {$jsFunameFlag};";
$jslink .= "var _playtype = 'r1';";
if ( $_5hFlag || $_8hFlag )
{
    $jslink .= "var _myHeader = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别1</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别2</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"bgClc_{$gametype}\"><th>类别3</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>'; ";
}
else
{
    $jslink .= "var _myHeader = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
    $jslink .= "var _myHeader2 = '<thead><tr class=\"td6\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
    $jslink .= "var _myHeader3 = '<thead><tr class=\"td0 bgClc_{$gametype}\"><th>类别</th><th>合计</th><th>项目</th><th>注单</th><th>输赢</th><th>项目</th><th>注单</th><th>输赢</th></tr></thead>';";
}
$jslink .= "var uMsg = new Array();";
$jslink .= "var uTitle = new Array();";
$jslink .= "uMsg[0] = '走飞完成！因更新资料需要时间,若画面未即时更新,请稍等一下,谢谢。';";
$jslink .= "uMsg[1] = '请输入赔率';";
$jslink .= "uMsg[2] = '请输入金额';";
$jslink .= "uMsg[3] = '请勾选号码';";
$jslink .= "uMsg[4] = '走飞内容';";
$jslink .= "uMsg[5] = '合计';";
$jslink .= "uMsg[6] = '笔';";
$jslink .= "uMsg[7] = '是否确定走飞?';";
$jsSrc = $_8hFlag?"8h":"";
if ( $gametype == 24 )
{
    $jsSrc = "pk10";
}
foreach ( $betname_3d as $key => $val )
{
    $jslink .= "uTitle['{$key}'] = '{$val}';";
}
$jslink .= "</script>";
$jslink .= "<script src=\"scr{$pg}/".$g_conf['language']."/unow".$jsSrc.".js\"></script>\n";
$ui->set("jslink" , $jslink);
$ui->header();
$tpl->show("main");
$ui->footer();